package Control;
/**
 * This class holds our settings for the A/D-Converter
 * 
 * @author kurmt1@bfh.ch, woodr1@bfh.ch, eichs2@bfh.ch
 * @version 1.0
 */
public class LCPDConverterSettings {
	private final int NumberOfChannel = 2;
	private float[] MaxVoltage;
	private float TotalTime;
	private float DisplayTime;
	private float TriggerLevel;
	private int[] Multiplicator;
	private float SampleRate;
	private boolean FFTMode = false;
	public enum LCPDTriggerMode{Normal,Auto,Roll,SingleSlope};
	public enum LCPDTriggerEdge{negative,positive};
	private LCPDTriggerEdge TriggerEdge = LCPDTriggerEdge.positive;
	private LCPDTriggerMode TriggerMode = LCPDTriggerMode.Normal;
	private String IP;
	public enum LCPDCouplingMode{AC,DC};
	private LCPDCouplingMode[] CouplingMode;
	private int BufferSize;
	private boolean Run;
	private boolean NewData;

	/**
	 * Create all arrays.
	 */
	public LCPDConverterSettings() {
		Multiplicator = new int[NumberOfChannel];
		MaxVoltage = new float[NumberOfChannel];
		CouplingMode=new LCPDCouplingMode[NumberOfChannel];
	}

	/**
	 * gets the Multiplicator for special sondes
	 * 
	 * @param Channel Number
	 * 
	 * @return Multiplicator value
	 */
	public final int getMultiplicator(int ChannelNumber) {
		if (ChannelNumber < NumberOfChannel)
			return Multiplicator[ChannelNumber];
		else
			return 0;
	}

	/**
	 * sets the Multiplicator for special sondes
	 * 
	 * @param Channel number
	 * 
	 * @param Multiplicator value
	 */
	public void setMultiplicator(int ChannelNumber, int value) {
		if (ChannelNumber < NumberOfChannel)
			Multiplicator[ChannelNumber] = value;
	}

	/**
	 * returns the trigger level
	 * 
	 * @return trigger level
	 */
	public final float getTriggerLevel() {
		return TriggerLevel;
	}

	/**
	 * sets the trigger level
	 * 
	 * @param value of the trigger level
	 */
	public void setTriggerLevel(float value) {
		TriggerLevel = value;
	}

	/**
	 * return the total time to sample, this value can reduced by the driver
	 * module.
	 * 
	 * @return total time to sample
	 */
	public final float getTotalTime() {
		return TotalTime;
	}

	/**
	 * sets the total time to sample, this value can reduced by the driver
	 * module.
	 * 
	 * @param total time to sample
	 */
	public void setTotalTime(float d) {
		TotalTime = d;
	}

	/**
	 * returns the maximum Voltage to display
	 * 
	 * @param Channel Number
	 */
	public final float getMaxVoltage(int ChannelNumber) {
		if (ChannelNumber < NumberOfChannel)
			return MaxVoltage[ChannelNumber];
		else
			return 0;
	}

	/**
	 * sets the maximum Voltage to display
	 * 
	 * @param Channel Number
	 * 
	 * @param Voltag level
	 */
	public void setMaxVoltage(int ChannelNumber, float value) {
		if (ChannelNumber < NumberOfChannel)
			MaxVoltage[ChannelNumber] = value;
	}

	/**
	 * returns wether the fft mode is enabled
	 * 
	 * @return true or false
	 */
	public final boolean getFFTMode() {
		return FFTMode;
	}

	/**
	 * set the scope into the fft mode
	 * 
	 * @param true or false
	 */
	public void setFFTMode(boolean value) {
		FFTMode = value;
	}

	/**
	 * returns the current sample rate, this value can be reedited by the Driver
	 * interface
	 * 
	 * @return Sample rate
	 */
	public final float getSampleRate() {
		return SampleRate;
	}

	/**
	 * sets the sample rate of the A/D-Converter, the Driver interface can
	 * adjust this value
	 * 
	 * @param Sample rate
	 */
	public void setSampleRate(float value) {
		SampleRate = value;
	}

	/**
	 * sets on witch channels edge the scope should trigger
	 * 
	 * @param 0 for negative 1 for positive
	 */
	public void setTriggerEdge(LCPDTriggerEdge Edge) {
		TriggerEdge = Edge;
	}

	/**
	 * get on whitch edge the scope triggers
	 * 
	 * @return 0 for negative 1 for positive
	 */
	public LCPDTriggerEdge getTriggerEdge() {
		return TriggerEdge;
	}

	/**
	 * sets the trigger mode of the scope
	 * 
	 * has to be programmed
	 * 
	 * @param
	 */
	public void setTriggerMode(LCPDTriggerMode Mode) {
		TriggerMode = Mode;
	}

	public LCPDTriggerMode getTriggerMode() {
		return TriggerMode;
	}

	/**
	 * get the IP of the server programm
	 * 
	 * @return IP-Adrress
	 */
	public final String getIP() {
		return IP;
	}

	/**
	 * sets the IP of the server programm
	 * 
	 * @param Ip Adress
	 */
	public void setIP(String pIP) {
		IP = new String(pIP);

	}

	/**
	 * returns the maximum time to display
	 * 
	 * @return maximum time
	 */
	public float getDisplayTime() {
		return DisplayTime;
	}

	/**
	 * sets the time to display chart, this value is fix and cannot be reduced
	 * 
	 * @param maximum time
	 */
	public void setDisplayTime(float value) {
		DisplayTime = value;
	}

	/**
	 * return the size of the Buffer
	 * 
	 * @param ChannelNumber
	 * @return true or false
	 */
	public final int getBufferSize() {
			return BufferSize;

	}

	/**
	 * sets the buffer size of a channel
	 * 
	 * @param Channel number
	 * @param Buffer size
	 */
	public void setBufferSize(int value) {
			BufferSize = value;
	}

	/**
	 * gets the Coupling Mode 
	 * 
	 * @param int ChannelNumber which channel
	 */
	public LCPDCouplingMode getCouplingMode(int ChannelNumber) {
		if (ChannelNumber<NumberOfChannel)
			return CouplingMode[ChannelNumber];
		else
			return null;
	}

	/**
	 * sets the Coupling Mode
	 * @param ChannelNumber
	 * @param couplingMode
	 */
	public void setCouplingMode(int ChannelNumber, LCPDCouplingMode couplingMode) {
		if (ChannelNumber<NumberOfChannel) 
			CouplingMode[ChannelNumber] = couplingMode;
	}
	
	/**
	 * show whether the system is running
	 * @return yes or no
	 */
	public boolean isRun() {
		return Run;
	}

	/**
	 * set whether the system is running
	 * @param run yes no
	 */
	public void setRun(boolean run) {
		Run = run;
	}
	
	/**
	 * if new data are available
	 * @return true
	 */
	public boolean isNewData() {
		return NewData;
	}

	/**
	 * set if new data are available
	 * @param newData
	 */
	public void setNewData(boolean newData) {
		NewData = newData;
	}
}
